import 'package:elevator/get/intl_keys.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';

import '../storage/local_storage.dart';

/// 语言国际化
class Messages extends Translations {
  @override
  Map<String, Map<String, String>> get keys => {
    'en_US': {
      IntlKeys.systemName: "Remote Lift Monitoring System",
      IntlKeys.loginLabel: "Remote Lift Monitoring System",
      IntlKeys.login:"Login",
      IntlKeys.password:"password",
      IntlKeys.username:"user name",
      IntlKeys.settingLanguage: "Language",
      IntlKeys.settingVersion: "Version",
      IntlKeys.settingAccount: "Account",
      IntlKeys.settingPhone: "Phone",
      IntlKeys.settingRole: "Role",
      IntlKeys.settingValid: "Valid Period",
      IntlKeys.ok: "ok",
      IntlKeys.cancel: "cancel",
      IntlKeys.settingLogout: "logout",
      IntlKeys.all: "All",
      IntlKeys.management: "Management",
      IntlKeys.admin: "Admin",
      IntlKeys.districtMgr: "District Manager",
      IntlKeys.depotMgr: "Depot Manager",
      IntlKeys.technican: "Technican",
      IntlKeys.client: "client",
      IntlKeys.tabSpecs: "Specs.",
      IntlKeys.tabStatus: "Status.",
      IntlKeys.tabError: "Error.",
      IntlKeys.tabMsg: "Signal Status",
      IntlKeys.tabAnalysis: "Special Signal Statistics",
      IntlKeys.errorReCordTimeTitle:'Error Record Time',
      IntlKeys.errorCodeTitle:'Error Code',
      IntlKeys.errorNameTitle:'Error Name',
      IntlKeys.lastMonthInfoTitle:'Latest Special Signal statistics',
      IntlKeys.specialMsg:'Special Signal',
      IntlKeys.times:'Count',


      IntlKeys.errorLoop:'Safety circuit failure',
      IntlKeys.allDoorOpen:'Door full open',
      IntlKeys.safetyKnifeTriggers:'DLS COUNT',
      IntlKeys.error:'Fault',
      IntlKeys.machineFallingGateLock:'Car Door Opened when Lift Running',
      IntlKeys.powerFailure:'Power failure',
      IntlKeys.doorFailure:'Door Response over 60s',
      IntlKeys.doorOperationOverload:'Door Open/Close Retry',
      IntlKeys.doorFullyOpenNoGateLock: 'Car Door Closed Switch always ON',
      IntlKeys.doorPcbFailure:'Car Control Unit Faulty',
      IntlKeys.startLoadingImage:"Start Downloading...",
      IntlKeys.imageLoading:"Image is loading...",
      IntlKeys.imageLoadWithWrongPath:"Image load failure with wrong path！",
      IntlKeys.imageDownloading:"Image is downloading...",
      IntlKeys.imageDownloadToLoad:"The downloaded image is loading completely",
      IntlKeys.imageDownloadingErrorTips:"Image download failed，please try again later！",
      IntlKeys.today : "TODAY",
      IntlKeys.emergencyInformation :'SVP Emergency signals',
      IntlKeys.signStatus :'Signal status',
      IntlKeys.mine :'Mine',
      IntlKeys.changeLanguage :'Switch Languages',
      IntlKeys.moreClickToExit :'Click again to exit',
      IntlKeys.openSetting :"Please open the settings and check the notification permission",
      IntlKeys.warning:'Warning',
      IntlKeys.nameError:'Username error',
      IntlKeys.nameNotEmpty:'Username cannot be empty',
      IntlKeys.pwdWrong:'Password error',
      IntlKeys.pwdNotEmpty:'Password cannot be empty',
      IntlKeys.loginig:"Logging in...",
      IntlKeys.loginFailure:'Login failed',
      IntlKeys.wrongNameOrPwd:'Incorrect username or password',
      IntlKeys.serverError:'Connection server error, please contact the administrator',
      IntlKeys.close: 'Close',
      IntlKeys.receiveMsgWhenOpen:'receive Msg when open',
      IntlKeys.receiveMsg:'receive Msg',
      IntlKeys.receiveMsgWithStr:'receive Msg %s',
      IntlKeys.subName:"Depot",
      IntlKeys.areaNo:"Job Site No.",
      IntlKeys.areaType:"Building Category",
      IntlKeys.areaName:"Building Name",
      IntlKeys.areaAddr:"Address(English)",
      IntlKeys.areaContact:"Sit Contact Person",
      IntlKeys.areaContactPhone:"Sit Contact Phone No.",
      IntlKeys.oneMonth:"one month",
      IntlKeys.halfAMonth:"half a month",
      IntlKeys.updateImg:"Replace the image",
      IntlKeys.success:"success",
    },
    'zh_Hans': {
      IntlKeys.systemName: "遠程升降機監控系統",
      IntlKeys.loginLabel: "遠程升降機監控系統",
      IntlKeys.login:"登入",
      IntlKeys.password:"帳戶密碼",
      IntlKeys.username:"用戶帳戶",
      IntlKeys.settingLanguage: "語言",
      IntlKeys.settingVersion: "版本號",
      IntlKeys.settingAccount: "賬號",
      IntlKeys.settingPhone: "手機號",
      IntlKeys.settingRole: "角色",
      IntlKeys.settingValid: "有效期",
      IntlKeys.ok: "確定",
      IntlKeys.cancel: "取消",
      IntlKeys.settingLogout: "退出登錄",
      IntlKeys.all: "全部",
      IntlKeys.management: "管理人",
      IntlKeys.admin: "行政人員",
      IntlKeys.districtMgr: "分區經理",
      IntlKeys.depotMgr: "分站經理",
      IntlKeys.technican: "工程人員",
      IntlKeys.client: "客戶",
      IntlKeys.tabSpecs: "規格",
      IntlKeys.tabStatus: "狀態",
      IntlKeys.tabError: "錯碼",
      IntlKeys.tabMsg: "信號狀態",
      IntlKeys.tabAnalysis: "特殊訊息統計",
      IntlKeys.errorReCordTimeTitle:'錯誤記錄時間',
      IntlKeys.errorCodeTitle:'錯碼',
      IntlKeys.errorNameTitle:'錯碼名稱',
      IntlKeys.lastMonthInfoTitle:'最近特殊訊息統計',
      IntlKeys.specialMsg:'特殊訊息',
      IntlKeys.times:'次数',
      IntlKeys.errorLoop:'安全回路故障',
      IntlKeys.allDoorOpen:'機門全開',
      IntlKeys.safetyKnifeTriggers:'保險刀觸發次數',
      IntlKeys.error:'故障',
      IntlKeys.machineFallingGateLock:'行機時轎廂門打開',
      IntlKeys.powerFailure:'電源故障',
      IntlKeys.doorFailure:'開關門反應時間超過60s',
      IntlKeys.doorOperationOverload:'門開關受阻自動重試',
      IntlKeys.doorFullyOpenNoGateLock: '轎廂門關門限位長期ON',
      IntlKeys.doorPcbFailure:'門控制器壞',
      IntlKeys.startLoadingImage:"开始加载图片...",
      IntlKeys.imageLoading:"图片正在加载...",
      IntlKeys.imageLoadWithWrongPath:"加载图片出现异常，图片路径不存在！",
      IntlKeys.imageDownloading:"正在下载图片...",
      IntlKeys.imageDownloadToLoad:"下载图片完成正在加载",
      IntlKeys.imageDownloadingErrorTips:"下载图片出现异常，请稍后重试！",
      IntlKeys.today : "今天",
      IntlKeys.emergencyInformation :'SVP紧急信号',
      IntlKeys.signStatus :'信号状态',
      IntlKeys.mine :'我的',
      IntlKeys.changeLanguage :'切换语言',
      IntlKeys.moreClickToExit :'再按一次退出',
      IntlKeys.openSetting :"请打开设置，勾选通知权限",
      IntlKeys.warning:'警告',
      IntlKeys.nameError:'用户名异常',
      IntlKeys.nameNotEmpty:'用户名不能为空',
      IntlKeys.pwdWrong:'密码异常',
      IntlKeys.pwdNotEmpty:'密码不能为空',
      IntlKeys.loginig:"登录中...",
      IntlKeys.loginFailure:'登录失败',
      IntlKeys.wrongNameOrPwd:'用户或密码错误',
      IntlKeys.serverError:'连接服务器异常，请联系管理员',
      IntlKeys.close: '关闭',
      IntlKeys.receiveMsgWhenOpen:'receive Msg when open',
      IntlKeys.receiveMsg:'receive Msg',
      IntlKeys.receiveMsgWithStr:'receive Msg %s',
      IntlKeys.subName:"分站名稱",
      IntlKeys.areaNo:"地盤編號",
      IntlKeys.areaType:"地盤類別",
      IntlKeys.areaName:"地盤名稱",
      IntlKeys.areaAddr:"地盤(中文)通信地址",
      IntlKeys.areaContact:"地盤聯絡人",
      IntlKeys.areaContactPhone:"地盤聯絡人電話",
      IntlKeys.oneMonth:"一個月",
      IntlKeys.halfAMonth:"半個月",
      IntlKeys.updateImg:"更新圖片",
      IntlKeys.success:"成功",
    }
  };

  static void changeUSLocal() {
    LocalStorage.setString("Language", "en");
    isCzLocal = false;
    var locale = const Locale('en', 'US');
    Get.updateLocale(locale);
  }

  static void change2CHLocal() {
    LocalStorage.setString("Language", "zh");
    isCzLocal = true;
    var locale = const Locale('zh', 'CH');
    Get.updateLocale(locale);
  }

  static bool isCzLocal = false;

  static Future<Locale> initHLocal() async {
    var local = await LocalStorage.get("Language");
    if('zh'==local){
      isCzLocal = true;
      return const Locale('zh', 'CH');
    }else{
      isCzLocal = false;
      return const Locale('en', 'US');
    }
  }

}